#!/usr/bin/csh

set CONFIGF        = "/opt2/LogCatcherTool/onshs/ne/tnxxx"
set PINGC          = "ping "
set CMDF_REPAIR    = "python WA_CPU_IIC_Repair.py --ipsource file --cfgfile ip.txt --interval 10"
set CMDF_RESTRD    = "python WA_CPU_IIC_RestoreDefault.py --ipsource file --cfgfile ip.txt --interval 10"

set HOMEW          = "/opt2/LogCatcherTool/workspace/suites/Auto_Reboot_wa"

clear
date
echo "-- IIC fix for prevent Auto Reboot : Start --"
cd $HOMEW

echo "-*******************************************-"
echo "The process is displayed while operating now. "
echo "-*******************************************-"
echo ""
echo -n "Input target ne group (1.SBTM, 2.SBB/SBM) : "
set gname = $<
switch ( $gname )
  case "1"
    echo "   *** For SBTM ***"
    cp $CONFIGF/.sbtm.tnxxx_port.py $CONFIGF/tnxxx_port.py
    touch ./ip_sbtm.txt
    cp ./ip_sbtm.txt ./ip.txt
    breaksw
  case "2"
    echo "   *** For SBB ***"
    cp $CONFIGF/.sbb.tnxxx_port.py $CONFIGF/tnxxx_port.py
    touch ./ip_sbb.txt
    cp ./ip_sbb.txt ./ip.txt
    breaksw
  default:
    echo "script end."
    date
    exit
endsw

echo "-*********************************************-"
echo "-           Please select menu                -"
echo "-                                             -"
echo "-  1. Repair IIC second channel (WA execute)  -"
echo "-  2. Restore Default IIC second channel      -"
echo "-                                             -"
echo "-*********************************************-"
echo ""
echo -n "Input < 1 or 2, q is stopped > : "
set gyn = $<
switch ( $gyn )
  case "1"
        set CMDF = "${CMDF_REPAIR}"
        echo "--------------------------------------------------------"
        echo " Starting Repair IIC second channel, Are you sure?"
        echo "--------------------------------------------------------"
        echo ""
        echo -n "Input < y or n , q is stopped > : "
        set gyna = $<
        switch ( $gyna )
          case "y"
            sleep 1; echo "script start. "; echo ""
            $CMDF
            breaksw
          case "q"
            echo "script end."
            exit
            breaksw
          case "n"
            echo "script end."
            exit
            breaksw
        endsw
    breaksw
  case "2"
        set CMDF = "${CMDF_RESTRD}"
        echo "--------------------------------------------------------"
        echo " ;CAUTION; RESTORE IIC second channel setting."
        echo " ;CAUTION; Please use this option ONLY in trouble, Are you sure?"
        echo "--------------------------------------------------------"
        echo ""
        echo -n "Input < y or n , q is stopped > : "
        set gyna = $<
        switch ( $gyna )
          case "y"
            sleep 1; echo "script start. "; echo ""
            $CMDF
            breaksw
          case "q"
            echo "script end."
            exit
            breaksw
          case "n"
            echo "script end."
            exit
            breaksw
        endsw
    breaksw
  case "q"
    echo "script end."
    exit
    breaksw
endsw

sleep 1; echo ""
sleep 1; echo ""
echo -n "  -- Thank you for your help.  " ; date
echo ""
